package usgs.bip.swap.process;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class URLUtil {



	public static String getURLContent(String urlString){
		
 
		String output = "";
		URL url;
	 
		try {
			 
			url = new URL(urlString);
			HttpURLConnection huc = (HttpURLConnection) url.openConnection();
		    //HttpURLConnection.setFollowRedirects(false);
		    huc.setConnectTimeout(20 * 1000);
		    huc.connect();
		    //read the result from the server
		    BufferedReader rd  = new BufferedReader(new InputStreamReader(huc.getInputStream()));
	        StringBuilder sb = new StringBuilder();
			String line = "";	        
	        while ((line = rd.readLine()) != null)
	          {
	              sb.append(line + '\n');
	          }
	

	        output = sb.toString();
			
			
		}catch(Exception e){
			e.printStackTrace();
		}
			
		return output;
	}

}
